﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Xml.Linq;
using System.Collections.Generic;
using System.Linq;
using CommonControls.ClassFiles;
namespace CommonControls.AboutApps
{
    public class About
    {
        string No = "";

        public List<AboutUsProperties> LoadAboutUsItems()
        {
            bool statusk = true;
            List<AboutUsProperties> objList = new List<AboutUsProperties>();
            try
            {
                XDocument xdoc = XDocument.Load("Data.xml");

                var list = from i in xdoc.Descendants("Item") select i;
                foreach (var element in list)
                {
                    AboutUsProperties objItem = new AboutUsProperties();
                    objItem.Id = element.Attribute("Id").Value;

                    if (objItem.Id == "3")
                    {
                        objItem.CountVisible = Visibility.Visible;
                        objItem.Name = element.Attribute("Name").Value;

                        if (IsolatedSettings.getStringValue("RelatedAppCount") != "")
                        {
                            objItem.Count = IsolatedSettings.getStringValue("RelatedAppCount");
                            if (objItem.Count.Length == 1)
                                objItem.margen = "28,-22,0,0";
                            else
                                objItem.margen = "23,-22,0,0";
                        }
                        else
                        {
                            objItem.margen = "23,-22,0,0";
                            objItem.Count = "10";
                        }
                    }
                    else
                    {
                        objItem.Name = element.Attribute("Name").Value;
                        objItem.CountVisible = Visibility.Collapsed;
                    }
                    if (objItem.Id == "5")
                    {
                        if(IsolatedSettings.getStringValue("AboutUsUpgrade") == "false")
                      
                            statusk = false;
                        
                    }
                    else
               
                           statusk = true;

                    if (statusk!=false)
                       
                            objList.Add(objItem);
                       
                   
                    
                }
            }
            catch (Exception ex)
            {
                Exception exNew = new Exception("Exception in LoadAboutUsItems Method In AboutUs file\n\n" + ex.Message + " \n\n Stack Trace \n" + ex.StackTrace);
                throw exNew;
            }

            return objList;
        }

    }
}
